
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.Iterator"%>
<%@page import="javax.rmi.PortableRemoteObject"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="DBConnection.ATeamObject"%>
<%@page import="manufacturerBean.Manufacturer"%>
<%@page import="manufacturerBean.ManufacturerHome"%>
<%@page import="GoodsBean.GoodsHome"%>
<%@page import="GoodsBean.Goods"%>
<%@page import="categorybean.Category"%>
<%@page import="categorybean.CategoryHome"%>
<%@page import="export.XMLExport"%>
<%-- 
    Document   : export
    Created on : Nov 27, 2011, 7:18:42 PM
    Author     : XPYCT
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <%
            Object homeCategoryObject;
            CategoryHome categoryHome;
            
            Object homeGoodsObject;
            GoodsHome goodsHome;

            Object homeManufacturerObject;
            ManufacturerHome manufacturerHome;

            XMLExport xmlex = new XMLExport();
            
            homeCategoryObject = new InitialContext().lookup("CategoryBean");
            categoryHome = (CategoryHome)PortableRemoteObject.narrow(
                homeCategoryObject,CategoryHome.class);
            Collection categories = categoryHome.findAll();
            Iterator categoriesIterator = categories.iterator();
            Collection categoriesID = new ArrayList();
            
            while (categoriesIterator.hasNext()){
                //category = (Category)categoriesIterator.next();
                
                categoriesID.add(
                        ((Category)categoriesIterator.next()).getObjectId());
            }    
            
            homeGoodsObject = new InitialContext().lookup("GoodsBean");
            goodsHome = (GoodsHome)PortableRemoteObject.narrow(
                homeGoodsObject,GoodsHome.class);
            Collection goodsObjects = goodsHome.findAllGoods();
            Iterator goodsIterator = goodsObjects.iterator();
            Collection goodsID = new ArrayList();
            
            while (goodsIterator.hasNext()){
                //category = (Category)categoriesIterator.next();
                
                goodsID.add(
                        ((Goods)goodsIterator.next()).getGoodsId());
            }    
            
            homeManufacturerObject = new InitialContext().lookup(
                    "ManufacturerBean");
            manufacturerHome = (ManufacturerHome)PortableRemoteObject.narrow(
                homeManufacturerObject,ManufacturerHome.class);
            Collection manufacturers = manufacturerHome.findAll();
            Iterator manufacturersIterator = manufacturers.iterator();
            Collection manufacturersID = new ArrayList();
            
            while (manufacturersIterator.hasNext()){
                //category = (Category)categoriesIterator.next();
                
                categoriesID.add(
                        ((Manufacturer)manufacturersIterator.next())
                        .getObjectId());
            }
            
            xmlex.addShop(26, categoriesID, manufacturersID, goodsID);
            xmlex.getTextXML();
            xmlex.validXML();
        %>
    </body>
</html>
